//
//  TTCell.m
//  123
//
//  Created by Wang on 14/11/19.
//  Copyright (c) 2014年 Wang. All rights reserved.
//

#import "TTCell.h"

@implementation TTCell

- (void)dealloc
{
    [_leftImage release];
    [_rightImage release];
    [_titleLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        
        self.titleLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        [_titleLabel setTintColor:[UIColor blackColor]];
        [_titleLabel setNumberOfLines:0];
        [_titleLabel sizeToFit];
        [_titleLabel setTextAlignment:NSTextAlignmentCenter];
        [self addSubview:_titleLabel];
        
        self.leftImage = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease];
        [self addSubview:_leftImage];
        
        self.rightImage = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease];
        [self addSubview:_rightImage];
        
        
        [_titleLabel setBackgroundColor:[UIColor yellowColor]];
        [_rightImage setBackgroundColor:[UIColor orangeColor]];
        [_leftImage setBackgroundColor:[UIColor blueColor]];
        
       
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [_leftImage setFrame:CGRectMake(self.frame.size.width / 10, self.frame.size.height / 8, self.frame.size.width / 10 * 3, self.frame.size.height / 2)];
    [_titleLabel setFrame:CGRectMake(self.frame.size.width / 10 - 10, self.frame.size.height / 8 + _leftImage.frame.size.height + 10, self.frame.size.width / 10 * 3 + 20, self.frame.size.height / 5)];
    [_rightImage setFrame:CGRectMake(self.frame.size.width / 5 * 3 + 10, 10, self.frame.size.width / 5 * 2 - 20, self.frame.size.height - 20)];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        
    }
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
